package com.sntk.registermanager.staff.query.mapper;

import com.sntk.registermanager.staff.application.dto.DoctorInfoDTO;
import com.sntk.registermanager.staff.domain.model.Gender;
import com.sntk.registermanager.staff.infrastructure.db.entity.DoctorInfoEntity;
import com.sntk.registermanager.staff.query.vo.DoctorInfoVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

/**
 * @author liuyunxia
 */
@Component
public class DoctorInfoMapper {

    public DoctorInfoVO transformToVO(DoctorInfoEntity entity){

        if(entity == null){
            return null;
        }
        DoctorInfoVO vo = new DoctorInfoVO();
        BeanUtils.copyProperties(entity, vo);
        Gender gender = Gender.get(entity.getGender());
        if(gender != null){
            vo.setGenderName(gender.getName());
        }
        return vo;
    }

    public DoctorInfoDTO transformToDTO(DoctorInfoEntity entity){
        if(entity == null){
            return null;
        }
        DoctorInfoDTO dto = new DoctorInfoDTO();
        BeanUtils.copyProperties(entity, dto);
        return dto;
    }
}
